package cn.good.yan.controller.t1;

import cn.good.yan.service.t1.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 演示 - Redis
 *
 * @author shengren.yan
 * @create 2023-11-08
 */
@RestController
@RequestMapping("/t1")
@Slf4j
@Api(tags = "订单接口")
public class OrderController {

    @Autowired
    private OrderService orderService;

    // 容易超卖问题
    @ApiOperation("单机版+锁")
    @GetMapping("/saleA")
    public String saleA() {
        orderService.sale();
        return "单机版+锁 ok";
    }

    // 完整分布式锁
    @ApiOperation("多机+分布式锁")
    @GetMapping("/saleB")
    public String saleB() {
        orderService.sale();
        return "单机版+锁 ok";
    }

}
